﻿using System;

namespace DBFile.ConsoleApp
{
	class Program
	{
		[STAThread]
		static void Main(string[] args)
		{
			if (args.Length == 1 || args.Length == 2)
			{
				string sourcefilename = null;
				string destfilename = null;
				int ret = 0;

				sourcefilename = args[0];
				if (args.Length > 1)
					destfilename = args[1];
				
				if (string.IsNullOrEmpty(destfilename))
					ret = DBFile.Core.DBFile.Move(sourcefilename);
				else
					ret = DBFile.Core.DBFile.Move(sourcefilename, destfilename);

				if (ret > 0)
					Console.WriteLine("File saved");
				else
					Console.WriteLine("Error occured");
			}
			else
			{
				ShowUsage();
			}
		}

		/// <summary>
		/// Shows the usage.
		/// </summary>
		static void ShowUsage()
		{
			Console.WriteLine("DBFile.ConsoleApp.exe <filepath>");
			Console.WriteLine("DBFile.ConsoleApp.exe <source> <destination>");
		}
	}
}
